package kr.pe.xissy.soulmate.helper;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class DateHelper {

	protected static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");

	public static String parseDateToString(Date date) {
		return DateHelper.dateFormat.format(date);
	}

	public static Date parseDate(String date) throws ParseException {
		return DateHelper.dateFormat.parse(date);
	}

	public static Double parseDateToDouble(Date date) {
		return Double.parseDouble(parseDateToString(date));
	}

	public static Date parseDate(Double date) throws ParseException {
		return parseDate(date.toString());
	}

	public static Date getTodayStartDate() {
		GregorianCalendar calendar = new GregorianCalendar();
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);

		return calendar.getTime();
	}

	public static Date getTomorrowStartDate() {
		GregorianCalendar calendar = new GregorianCalendar();
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);
		calendar.add(Calendar.DATE, 1);

		return calendar.getTime();
	}

}
